﻿#pragma once

#include <nlohmann/json.hpp>
#include <string>
#include "plug_dynamic/base_plug_module.hpp"

class BaseNet{
public:
    enum NetType {
        TCP,
        UDP,
        MQTT,
        MQTT_SSL,
        MODBUS_TCP,
        HTTP,
        HTTP_SSL
    };

    NLOHMANN_JSON_SERIALIZE_ENUM(NetType, {
        { NetType::TCP, "tcp" },
        { NetType::UDP, "udp" },
        { NetType::MQTT, "mqtt" },
        { NetType::MQTT_SSL, "mqtt_ssl" },
        { NetType::MODBUS_TCP, "modbus_tcp" },
        { NetType::HTTP, "http" },
        { NetType::HTTP_SSL, "http_ssl" }
    });


    NetType m_net_type;

    /// @brief IP地址
    std::string ip;

    /// @brief 端口号
    int port;

    /// @bref 模块
    BasePlugModule::weak_ptr plug;

    /// @brief 初始化
    virtual void init() {

    }

    /// @brief 执行
    virtual void run() {

    }
};

